package com.ewzj.bigdata.mvp.ui.adapter;

import android.net.Uri;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ewzj.bigdata.R;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.http.imageloader.glide.ImageConfigImpl;
import com.jess.arms.utils.ArmsUtils;

import java.util.List;

/**
 * Author:zhangjing
 * Time:2018/3/14  上午11:03
 * Name: this is PicItemAdapter
 * Email:zhangjingworkmol@163.com
 */

public class PicItemAdapter extends BaseQuickAdapter<Uri,BaseViewHolder>{
    ImageLoader imageLoader;
    public PicItemAdapter(@Nullable List<Uri> data) {
        super(R.layout.item_pic, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Uri item) {
       if (imageLoader==null){
           imageLoader= ArmsUtils.obtainAppComponentFromContext(mContext).imageLoader();
       }
        ImageView imageView= (ImageView) helper.itemView;
        imageLoader.loadImage(mContext, ImageConfigImpl.builder()
                .imageView(imageView)
                .url(item.toString())
                .build());
    }


}
